package com.easyctrl.ldy.view;

import com.easyctrl.ldy.activity.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class NavigataView extends RelativeLayout {

	private LayoutInflater mInflater;
	private View view;
	private Button leftButton;
	private TextView title;
	private Button rightButton;
	
	public Button getLeftButton() {
		return leftButton;
	}
	public Button getRightButton() {
		return rightButton;
	}

	public NavigataView(Context context, AttributeSet attrs) {
		super(context, attrs); 
		mInflater = LayoutInflater.from(context);
		view = mInflater.inflate(R.layout.navagta_view, this);
		
		leftButton = (Button) view.findViewById(R.id.leftbutton);
		rightButton = (Button) view.findViewById(R.id.rigthbutton);
		title = (TextView) view.findViewById(R.id.title);
		
		TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.navation);
		String left = array.getString(R.styleable.navation_n_leftButton);
		String t = array.getString(R.styleable.navation_n_title);
		String right = array.getString(R.styleable.navation_n_rightButton);
	 
		if(left != null && left.length() > 0){
			leftButton.setText(left);
		}
		
		if(t != null && t.length() > 0){
			title.setText(t);
		}
		
		if(right != null && right.length() > 0){
			rightButton.setText(right);
			rightButton.setVisibility(View.VISIBLE);
		}
		
	}
}
